home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1533 / registry.bat < prev    next >
DOS Batch File  |  1997-02-24  |  6KB  |  205 lines

  1. @echo off
  2. rem :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3. rem : The following variables may be changed to customize this utility
  4. rem : to a specific system configuration:
  5.  
  6. rem : The folder to store copies of the registry files:
  7. set _BACKUPDIR_=C:\REGBKUP
  8.  
  9. rem : The folder in which Windows is installed:
  10. set _WINDIR_=C:\WINDOWS
  11.  
  12. rem : The root folder for user profiles
  13. set _PROFILESDIR_=%_WINDIR_%\Profiles
  14. rem : uncomment the following line to skip processing user profiles
  15. rem set _PROFILESDIR_=_
  16.  
  17. rem : The rest of this file does not need to be modified
  18. rem :::::::::::::::::::::::::::::::::::::::::::::::::::::::
  19.  
  20. echo --------------------------------------------------------------------
  21. echo Registry Backup/Restore utility (a part of Folder Guard)
  22. echo Copyright (c) 1997, Chaosoft. All rights reserved.
  23. echo --------------------------------------------------------------------
  24.  
  25. goto _start
  26.  
  27. :_message
  28.  
  29. echo --------------------------------------------------------------------
  30. echo Usage: enter at the MS-DOS command prompt (in MS-DOS mode only!):
  31. echo   REGISTRY BACKUP  - to back up the registry
  32. echo   REGISTRY RESTORE - to restore the registry
  33. echo --------------------------------------------------------------------
  34. echo Attention: this utility is set up to use the following folders:
  35. echo           Registry backup folder: %_BACKUPDIR_%
  36. echo                   Windows folder: %_WINDIR_%
  37. echo    Root folder for user profiles: %_PROFILESDIR_%
  38. echo If your system configuration is different, edit 'REGISTRY.BAT'!
  39. echo ---------------------------------------------------------------------
  40.  
  41. goto _exit
  42.  
  43. :_start
  44.  
  45. rem : Verify that _WINDIR_ specifies valid Windows folder
  46. rem : (the folder must contain WIN.COM)
  47.  
  48. if exist %_WINDIR_%\WIN.COM goto _01
  49. echo E R R O R : Invalid Windows folder specified: '%_WINDIR_%'
  50. echo Edit 'REGISTRY.BAT' !
  51. goto _exit
  52. :_01
  53.  
  54. rem : Verify that the Profiles folder exists, if specified
  55. if [%_PROFILESDIR_%]==[_] goto _02
  56. if exist %_PROFILESDIR_%\NUL goto _02
  57. echo Cannot find the Profiles folder specified: '%_PROFILESDIR_%'
  58. echo Press any key to continue and SKIP processing the user profiles
  59. echo or press Ctrl+Break to abort
  60. pause > NUL
  61. set _PROFILESDIR_=_
  62. :_02
  63.  
  64. rem: Analyze the command line arguments supplied
  65.  
  66. if [%2]==[] goto _04
  67. echo E R R O R : Too many command line arguments specified
  68. goto _message
  69. :_04
  70.  
  71. if not [%1]==[] goto _05
  72. echo E R R O R : No command line argument specified
  73. goto _message
  74. :_05
  75.  
  76. rem : Validate the argument passed
  77.  
  78. if [%1]==[BACKUP] goto _do_work
  79. if [%1]==[backup] goto _do_work
  80. if [%1]==[RESTORE] goto _do_work
  81. if [%1]==[restore] goto _do_work
  82.  
  83. echo E R R O R: Invalid command line argument: '%1'
  84. goto _message
  85.  
  86. :_do_work
  87.  
  88. rem : Make sure we are running in MS-DOS mode
  89. if [%windir%]==[] goto _06
  90. echo E R R O R: Cannot backup/restore registry while Windows is running.
  91. goto _exit
  92. :_06
  93.  
  94. if [%1]==[BACKUP] goto _backup
  95. if [%1]==[backup] goto _backup
  96. if [%1]==[RESTORE] goto _restore
  97. if [%1]==[restore] goto _restore
  98.  
  99. rem :::::::::::::::::::::::::::::::
  100. rem ::  Backing up the Registry  ::
  101. rem :::::::::::::::::::::::::::::::
  102.  
  103. :_backup
  104.  
  105. echo This will backup the Registry into folder:
  106. echo   %_BACKUPDIR_%
  107. echo assuming Windows is installed in folder:
  108. echo   %_WINDIR_%
  109.  
  110. if [%_PROFILESDIR_%]==[_] goto _07
  111. echo assuming user profiles are located in subfolders of:
  112. echo   %_PROFILESDIR_%
  113. :_07
  114.  
  115. echo Press any key to continue or Ctrl+Break to abort.
  116. echo --------------------------------------------------------------------
  117. pause > NUL
  118.  
  119. rem : create the backup folder if it does not exist
  120.  
  121. if exist %_BACKUPDIR_%\NUL goto _09
  122. md %_BACKUPDIR_%
  123. :_09
  124.  
  125. echo * Backing up System.dat...
  126. attrib -R -S -H %_WINDIR_%\System.dat
  127. copy /Y %_WINDIR_%\System.dat %_BACKUPDIR_%
  128. attrib +R +S +H %_WINDIR_%\System.dat
  129.  
  130. echo * Backing up User.dat...
  131. attrib -R -S -H %_WINDIR_%\User.dat
  132. copy /Y %_WINDIR_%\User.dat %_BACKUPDIR_%
  133. attrib +R +S +H %_WINDIR_%\User.dat
  134.  
  135. if [%_PROFILESDIR_%]==[_] goto _11
  136.  
  137. rem : Create subfolder to store user profiles
  138. if exist %_BACKUPDIR_%\NUL goto _10
  139. md %_BACKUPDIR_%\PROFILES
  140. :_10
  141.  
  142. echo * Backing up user profiles...
  143. attrib -R -S -H %_PROFILESDIR_%\*.dat /S
  144. echo d | xcopy %_PROFILESDIR_%\*.dat %_BACKUPDIR_%\PROFILES /S
  145. attrib +R +S +H %_PROFILESDIR_%\*.dat /S
  146.  
  147. :_11
  148.  
  149. goto _exit
  150.  
  151. rem ::::::::::::::::::::::::::::::
  152. rem ::  Restoring the Registry  ::
  153. rem ::::::::::::::::::::::::::::::
  154.  
  155. :_restore
  156.  
  157. if exist %_BACKUPDIR_%\NUL goto _12
  158. echo E R R O R: Backup folder '%_BACKUPDIR_%' does not exist.
  159. echo Edit 'REGISTRY.BAT' !
  160. goto _exit
  161. :_12
  162.  
  163. echo This will restore the Registry from folder:
  164. echo   %_BACKUPDIR_%
  165. echo assuming Windows is installed in folder:
  166. echo   %_WINDIR_%
  167.  
  168. if [%_PROFILESDIR_%]==[_] goto _13
  169. echo assuming user profiles are located in subfolders of:
  170. echo   %_PROFILESDIR_%
  171. :_13
  172.  
  173. echo Press any key to continue or Ctrl+Break to abort.
  174. echo --------------------------------------------------------------------
  175. pause > NUL
  176.  
  177. echo * Restoring System.dat...
  178. attrib -R -S -H %_WINDIR_%\System.dat
  179. copy /Y %_BACKUPDIR_%\System.dat %_WINDIR_%
  180. attrib +R +S +H %_WINDIR_%\System.dat
  181.  
  182. echo * Restoring User.dat...
  183. attrib -R -S -H %_WINDIR_%\User.dat
  184. copy /Y %_BACKUPDIR_%\User.dat %_WINDIR_%
  185. attrib +R +S +H %_WINDIR_%\User.dat
  186.  
  187. if [%_PROFILESDIR_%]==[_] goto _15
  188. echo * Restoring user profiles...
  189. attrib -R -S -H %_PROFILESDIR_%\*.dat /S
  190. echo d | xcopy %_BACKUPDIR_%\PROFILES\*.dat %_PROFILESDIR_% /S
  191. attrib +R +S +H %_PROFILESDIR_%\*.dat /S
  192. :_15
  193.  
  194. goto _exit
  195.  
  196. :_exit
  197.  
  198. rem : Clean up the environment
  199.  
  200. set _BACKUPDIR_=
  201. set _WINDIR_=
  202. set _PROFILESDIR_=
  203.  
  204. pause
  205.